home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / sightmap / queue.cls < prev    next >
Text File  |  1999-01-12  |  1KB  |  53 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4.   Persistable = 0  'NotPersistable
  5.   DataBindingBehavior = 0  'vbNone
  6.   DataSourceBehavior  = 0  'vbNone
  7.   MTSTransactionMode  = 0  'NotAnMTSObject
  8. END
  9. Attribute VB_Name = "queue"
  10. Attribute VB_GlobalNameSpace = False
  11. Attribute VB_Creatable = True
  12. Attribute VB_PredeclaredId = False
  13. Attribute VB_Exposed = False
  14. Option Explicit
  15.  
  16. 'Queue.cls
  17.  
  18. Private Q() As Variant
  19. Private Front As Integer
  20. Private Rear As Integer
  21. Private QueueSize As Integer
  22.  
  23. Public Function EmptyQ() As Boolean
  24.     EmptyQ = (Rear = Front)
  25. End Function
  26.  
  27. Public Sub ClearQ(QSize As Integer)
  28.  
  29.     ReDim Q(QSize)
  30.     Front = QSize
  31.     Rear = QSize
  32.     QueueSize = QSize
  33.     
  34. End Sub
  35.  
  36. Public Sub EnQ(NewVal As Variant)
  37.     If Rear = QueueSize Then
  38.        Rear = 1
  39.     Else
  40.        Rear = Rear + 1
  41.     End If
  42.     Q(Rear) = NewVal
  43. End Sub
  44.  
  45. Public Sub DeQ(Entry As Variant)
  46.     If Front = QueueSize Then
  47.         Front = 1
  48.     Else
  49.         Front = Front + 1
  50.     End If
  51.     Entry = Q(Front)
  52. End Sub
  53.